import java.util.concurrent.atomic.AtomicInteger;

public class dmeo {
    public static void main(String[] args) throws InterruptedException {
        AtomicInteger count = new AtomicInteger();
        Thread t = new Thread(()->{
            while(!Thread.currentThread().isInterrupted()){
                System.out.println("hello thread");
                count.getAndIncrement();
            }
        });
        t.start();
        Thread.sleep(1000);
        t.interrupt();
        System.out.println(count);
    }
}
